package Lee_code;

public class Lee_494 {

    public static int count;
    public static int end;
    public int findTargetSumWays(int[] nums, int target)
    {
        end = target;
        dfs(nums,1,-nums[0]);
        dfs(nums,1,nums[0]);
        return count;
    }
    public static void dfs(int[] nums, int index, int sum) //下一个的index, 已有的sum
    {
        if(index == nums.length)
        {
            if(sum == end)
                count++;
        }
        else
        {
            int temp = nums[index];
            index++;
            dfs(nums, index, sum-temp);
            dfs(nums, index, sum+temp);
        }

    }
    public static void main(String[] args) {

    }
}
